package itbour.onetouchshow.activity.version1_3;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.OneToucDialog;
import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.ServiceException;
import com.andview.adapter.BaseRecyclerHolder;
import com.xiao.nicevideoplayer.LogUtil;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import itbour.onetouchshow.App;
import itbour.onetouchshow.R;
import itbour.onetouchshow.activity.login.ExtractFrameWorkThread;
import itbour.onetouchshow.activity.version1_2.CutVideoActivity;
import itbour.onetouchshow.activity.version1_2.CutVideoPresenter;
import itbour.onetouchshow.bean.user.UserMakeTag;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.utils.FileUtils;
import itbour.onetouchshow.utils.L_;
import itbour.onetouchshow.utils.T_;
import itbour.onetouchshow.utils.UIUtils;
import itbour.onetouchshow.utils.aliyun.AliRequestUtils;

import static android.media.MediaMetadataRetriever.OPTION_CLOSEST;

/**
 * Created by Administrator on 2018/2/28.
 * <p>
 * <p>
 * 设置封面
 */

public class VideoCoverActivity extends CutVideoActivity {


    @BindView(R.id.ig_cover_start)
    protected ImageView ig_cover_start;

    @BindView(R.id.id_tv_del_cover)
    protected TextView id_tv_del_cover;

    @BindView(R.id.id_tv_show_tag)
    protected TextView id_tv_show_tag;

    @BindView(R.id.id_covet_select_tag)
    protected ImageView id_covet_select_tag;
    @BindView(R.id.id_ig_show_tag)
    protected ImageView id_ig_show_tag;
    protected long MIN_CUT_DURATION = 10000;// 最小剪辑时间
    protected int igCoverWidth = UIUtils.dp2px(18);
    protected String docId;  //作品id
    protected double videoW;
    protected double videoH;
    protected boolean islocalhost;//是否是本地视频
    protected double startscrollPos;
    /*如果有背景  则多出一个封面0.2秒的位置*/
    //计算0.2秒占视频的宽度
    protected int converWidth;
    @BindView(R.id.id_ly_line)
    RelativeLayout id_ly_line;
    Double[] frameTimes;
    String pathFile;
    //视频封面时间
    private double converDuration;
    private boolean ishasCover = true;
    private Handler imageHander = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            Bitmap info = (Bitmap) msg.obj;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (id_ig_show_tag != null && info != null)
                        id_ig_show_tag.setImageBitmap(info);
                }
            });
        }
    };

    /**
     * 查找最接近目标值的数，并返回
     *
     * @param array
     * @param targetNum
     * @return
     */

    public static Double binarysearchKey(Double[] array, double targetNum) {
        Arrays.sort(array);
        int targetindex = 0;
        int left = 0, right = 0;
        for (right = array.length - 1; left != right; ) {
            int midIndex = (right + left) / 2;
            int mid = (right - left);
            double midValue = array[midIndex];
            if (targetNum == midValue) {
                return targetNum;
            }

            if (targetNum > midValue) {
                left = midIndex;
            } else {
                right = midIndex;
            }
            if (mid <= 2) {
                break;
            }
        }
        Double integer = Math.abs(array[left] - targetNum) < Math.abs(array[right] - targetNum) ? array[left] : array[right];
        //Integer integer = (array[right] - array[left]) / 2 > targetNum ? array[right] : array[left];
        L_.e("和要查找的数：" + targetNum + "最接近的数：" + integer);
        return integer;

    }

    @Override
    protected void afterCreate(Bundle savedInstanceState) {
        //重设基线的宽度 占据屏幕2/3
        if (mPresenter == null) {
            mPresenter = new CutVideoPresenter(this);
        }
        mscaleWidth = UIUtils.WH()[0] * 2 / 3;
        onSuperAfter();
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//显示状态栏
        //idRyCount.setVisibility(View.GONE);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) ig_cover_start.getLayoutParams();
        igSeletor.setScaleType(ImageView.ScaleType.FIT_XY);
        //避免抽帧超出
        layoutParams.width = igCoverWidth;
        layoutParams.leftMargin = UIUtils.WHD()[0] / 3;
        RelativeLayout.LayoutParams id_ly_lineLayoutParams = (RelativeLayout.LayoutParams) id_ly_line.getLayoutParams();
        id_ly_lineLayoutParams.leftMargin = UIUtils.WHD()[0] / 3 + igCoverWidth / 2;
        //id_ly_line.setLayoutParams(id_ly_lineLayoutParams);
        RelativeLayout.LayoutParams covetTagParams = (RelativeLayout.LayoutParams) id_covet_select_tag.getLayoutParams();
        //避免抽帧超出
        covetTagParams.width = igCoverWidth;
        covetTagParams.leftMargin = UIUtils.WHD()[0] / 3;
        igSeletor.setVisibility(View.GONE);
        if (!ishasCover) {
            id_tv_del_cover.setVisibility(View.GONE);
        }
        id_tv_del_cover.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        id_tv_del_cover.getPaint().setAntiAlias(true);//抗锯齿
        id_tv_del_cover.setText(Html.fromHtml("删除封面"));
        id_tv_del_cover.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // mPresenter.removevideoUserdoccover_v1_3(docId);
                deleteCoverDialog();
            }
        });

        id_tv_show_tag.setText("左右滑动选择视频封面");

    }

    public void onSuperAfter() {
        EventBus.getDefault().register(this);
        getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //隐藏状态栏
        //getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//显示状态栏
        //getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN );
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            videoUrl = extras.getString("videoUrl");
            docId = extras.getString("docId");
            videoW = extras.getDouble("videoW");
            videoH = extras.getDouble("videoH");
            ishasCover = extras.getBoolean("ishaveCover");
            islocalhost = extras.getBoolean("islocalhost");
            mDuration = (long) extras.getDouble("duration");
            converDuration = extras.getDouble("coverDuration");
        }

        mPresenter.getuserDockeyframetimes_v1_3(docId);

        int[] whd = UIUtils.WHD();
        int visableW = whd[0];
        float videoScale = (float) (videoW * 1.0f / visableW);
        videoH = (int) (videoH * 1.0f / videoScale);
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) landLayoutVideo.getLayoutParams();
        lp.leftMargin = 0;
        lp.topMargin = 0;
        lp.bottomMargin = 0;
        lp.width = UIUtils.WH()[0];
        lp.height = (int) videoH;

        list = new ArrayList<>();
        baseInit();
        //MIN_CUT_DURATION = setMinDuration();
        idRyRoot.setVisibility(View.GONE);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) igSeletor.getLayoutParams();
        igSeletor.setScaleType(ImageView.ScaleType.FIT_XY);
        //避免抽帧超出
        layoutParams.width = (int) mscaleWidth + UIUtils.dp2px(2);
        layoutParams.leftMargin = leftMargen - UIUtils.dp2px(1);

        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) idRyCount.getLayoutParams();
        layoutParams2.width = (int) mscaleWidth;
        layoutParams2.leftMargin = leftMargen;

        rvVideo.setHasFixedSize(true);
        LinearLayoutManager ms = new LinearLayoutManager(VideoCoverActivity.this);
        ms.setOrientation(LinearLayoutManager.HORIZONTAL);// 设置 recyclerview 布局方式为横向布局
        //  LinearLayoutManager 种 含有3 种布局样式  第一个就是最常用的 1.横向 , 2. 竖向,3.偏移
        rvVideo.setLayoutManager(ms);
        rvVideo.addOnScrollListener(setOnRecyclviewSollerListener());
        onStartPlay(videoUrl, "");
        if (ishasCover) {
            landLayoutVideo.seekTo((long) (converDuration * 1000));
        }
        //String s = UIUtils.videoWHDA(videoUrl)[2];
        // initEditVideo(Long.valueOf(String.valueOf(duration)));
        if (mDuration == 0) {
            mDuration = setMinDuration();
        }

        //分成是N等分
        MAX_COUNT_RANGE = Integer.valueOf(String.valueOf(mDuration / 1000));
        if (mDuration < MIN_CUT_DURATION) {
            MIN_CUT_DURATION = mDuration;
        }
        //取整
        double end = MIN_CUT_DURATION / 1000;
        L_.e("MIN_CUT_DURATION / 1000:" + MIN_CUT_DURATION / 1000);
        float scale = MIN_CUT_DURATION * 1.0f / mDuration;
        //减去左边的间距
        maxWidth = mscaleWidth / scale;

        if (ishasCover) {
            //0.2所占得宽度
            converWidth = (int) ((0.2 / end) * maxWidth);
        }
        averageMsPx = (float) (mDuration / maxWidth);
        //重新设置ItmeWidth
        mItemWidth = (int) Math.ceil(maxWidth / MAX_COUNT_RANGE);
        list.clear();
        for (int i = 0; i < MAX_COUNT_RANGE + 2; i++) {
            list.add(null);
        }
        videoAdapter = new CocerVideoAdapter(VideoCoverActivity.this, list, R.layout.video_item);
        rvVideo.setAdapter(videoAdapter);
        if (idRyRoot != null && idRyRoot.getVisibility() == View.GONE) {
            idRyRoot.setVisibility(View.VISIBLE);
        }

        onstartGetVideImage();
    }

    @Override
    public void getKeyFrameTimes(Double[] times) {
        this.frameTimes = times;
    }

    @Override
    protected void onstartGetVideImage() {
        int type;
        long start = 0;
        if (islocalhost) {
            type = 2;
        } else {
            type = 1;
        }
        if (ishasCover) {
            start = (long) (converDuration * 1100);
        }
        mExtractFrameWorkThread = new ExtractFrameWorkThread(type, mItemWidth, UIUtils.dip2px(80), mUIHandler, videoUrl, null, start, mDuration, MAX_COUNT_RANGE);
        mExtractFrameWorkThread.start();

    }

    @Override
    public long setMinDuration() {
        if (islocalhost) {
            return Integer.valueOf(UIUtils.videoDuration(2, videoUrl));
        } else {
            return Integer.valueOf(UIUtils.videoDuration(1, videoUrl));
        }

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_videocover;
    }

    @Override
    protected OnRecyclviewSollerListener setOnRecyclviewSollerListener() {
        return new OnRecyclviewSollerListener();
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (landLayoutVideo.isPlaying()) {
            landLayoutVideo.pause();
        }
    }

    @Override
    protected boolean isNeedPlay() {
        return false;
    }

    @Override
    protected boolean isConverPage() {
        return true;
    }

    protected int getScrollXDistance() {
        LinearLayoutManager layoutManager = (LinearLayoutManager) rvVideo.getLayoutManager();
        int position = layoutManager.findFirstVisibleItemPosition();
        View firstVisibleChildView = layoutManager.findViewByPosition(position);
        int itemWidth = firstVisibleChildView.getWidth();
        //如果大于1加上前面head的宽度
        if (position >= 1) {
            return (position) * itemWidth - firstVisibleChildView.getLeft() + (UIUtils.WHD()[0] / 3 + igCoverWidth / 2) - itemWidth;
        } else {
            return (position) * itemWidth - firstVisibleChildView.getLeft();
        }
    }

    @Override
    protected View getFootView() {
        View footview = UIUtils.inflate(R.layout.video_item_place);
        TextView textView = footview.findViewById(R.id.id_ry_place);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textView.getLayoutParams();
        layoutParams.width = (int) (Math.floor(UIUtils.WH()[0] * 0.44) + UIUtils.WHD()[0] / 3 - leftMargen - igCoverWidth / 2 + UIUtils.dp2px(2));
        // layoutParams.height = (int) (UIUtils.WH()[0] / 0.44);
        textView.setLayoutParams(layoutParams);
        LogUtil.i(" layoutParams1.width" + layoutParams.width);
        return footview;
    }

    protected View getHeadView() {
        View footview = UIUtils.inflate(R.layout.video_item_place);
        TextView textView = footview.findViewById(R.id.id_ry_place);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textView.getLayoutParams();
        layoutParams.width = UIUtils.WHD()[0] / 3 + igCoverWidth / 2;
        // layoutParams.height = (int) (UIUtils.WH()[0] / 0.44);
        textView.setLayoutParams(layoutParams);
        LogUtil.i(" layoutParams1.width" + layoutParams.width);
        return footview;
    }


    protected void getBitmapForVideo(String url, long currentTime) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                MediaMetadataRetriever mmr = new MediaMetadataRetriever();
                if (islocalhost) {
                    mmr.setDataSource(url);
                } else {
                    mmr.setDataSource(url, new HashMap<>());
                }
                //获取第一帧图像的bitmap对象 单位是微秒
                Message msg = Message.obtain();
                msg.obj = mmr.getFrameAtTime((currentTime * 1000), OPTION_CLOSEST);
                if (msg.obj != null) {
                    L_.e("getBitmapForVideo" + msg.obj.toString());
                } else {
                    L_.e("getBitmapForVideo 失败");
                }

                imageHander.sendMessage(msg);
            }
        }).start();

    }

    @Override
    protected void initTitle() {
        super.initTitle();
        setTitleText("设置封面");
        getToolBarView().getRightTextView().setVisibility(View.VISIBLE);
        getToolBarView().getRightTextView().setText("保存");
        getToolBarView().getRightTextView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (list == null || list.size() == 0) {
                    T_.showCustomToast("请稍等...");
                    return;
                }
                //Bitmap bitmapForVideo = getBitmapForVideo(videoUrl, (long) startscrollPos);
                // settingConver(bitmapForVideo);

                showProgressDialogWithText("正在保存封面");
                long currentPosition = landLayoutVideo.getCurrentPosition();
                if (ishasCover) {
                    currentPosition -= (converDuration * 1000);
                }
                L_.e("startscrollPos currentPosition -= (converDuration * 1000)  " + currentPosition);
                //请求接口
                DecimalFormat df = new DecimalFormat("#0.0000");
                //String format = df.format(currentPosition / 1000);
                Double format = Double.valueOf(currentPosition / 1000.0);
                // upDateUserInfo(Double.valueOf(format));
                L_.e("startscrollPos currentPosition -= (converDuration * 1000)  " + format);
                mPresenter.setVideouserdoccover_v1_3(docId, format);
            }
        });

        getToolBarView().getLeftimageView().setVisibility(View.VISIBLE);
        getToolBarView().getLeftimageView().setImageResource(R.mipmap.cancle_icon);
        getToolBarView().getLeftimageView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

    }

    public void settingConver(Bitmap bitmap) {
        showProgressDialogWithText("上传中...");
        new Thread(new Runnable() {
            @Override
            public void run() {
                String IMAGE = ".png";
                String imageName = AliRequestUtils.getInstance().createFileName("image", App.getLoginBean().getUserInfo().getUserId() + "") + IMAGE;
                // oneTouchProgressDialog = new OneTouchProgressDialog();
                //
                try {
                    //上传封面
                    AliRequestUtils.getInstance().setName(imageName);
                    File imagefile = AliRequestUtils.getInstance().saveBitmapFile(bitmap, FileUtils.getJpgFileName(videoUrl));
                    App.ossClient.putObject(AliRequestUtils.getInstance().putObjectRequest(imagefile.getAbsolutePath()));
                    pathFile = AppConfig.UPLOAD_ALYUN + imageName;
                    L_.e("imagefile" + pathFile);

                    //请求接口
                    DecimalFormat df = new DecimalFormat("#0.0000");
                    String format = df.format(startscrollPos / 100 / 10);
                    // upDateUserInfo(Double.valueOf(format));
                    mPresenter.setVideouserdoccover_v1_3(docId, Double.valueOf(format));

                    dismissProgressDialog();
                } catch (ClientException e) {
                    e.printStackTrace();
                    L_.e("ErrorCode", e.getMessage());
                    T_.showToastWhendebug("上传失败");
                    dismissProgressDialog();
                } catch (ServiceException e) {
                    e.printStackTrace();
                    L_.e("ErrorCode", e.getErrorCode());
                    L_.e("RequestId", e.getRequestId());
                    L_.e("HostId", e.getHostId());
                    L_.e("RawMessage", e.getRawMessage());
                    T_.showToastWhendebug("上传失败");
                    dismissProgressDialog();

                }
            }
        }).start();
    }

    @SuppressLint("ValidFragment")
    public void deleteCoverDialog() {
        String context = "确定删除封面";
        new OneToucDialog.Builder(this)
                .content(context)
                .positiveText("删除").onPositive(new OneToucDialog.SingleButtonCallback() {
            @Override
            public void onClick(OneToucDialog dialog, DialogAction which) {
                showProgressDialogWithText("正在删除封面");
                mPresenter.removevideoUserdoccover_v1_3(docId);
            }
        })
                .negativeText("取消").onNegative(new OneToucDialog.SingleButtonCallback() {
            @Override
            public void onClick(OneToucDialog dialog, DialogAction which) {
                Log.e("TAH", "点击确定");
            }
        }).setType(OneToucDialog.Builder.ONE_TOUCH_TYPE)
                .cancelable(false)
                .show();


    }

    @Override
    public void setVideouserdoccoverSuccess() {
        super.setVideouserdoccoverSuccess();
        mPresenter.loadDocPreview(docId);

    }

    @Override
    public void loadFaild(String error) {
        super.loadFaild(error);
        dismissProgressDialog();
    }

    @Override
    public void loadDocPreviewSuccess() {
        super.loadDocPreviewSuccess();
        // T_.showCustomToast(response);
        dismissProgressDialog();
        finish();
        //EventBus.getDefault().post(1800);
        UserMakeTag userMakeTag = UserMakeTag.SETCOVER;
        // userMakeTag.setTag(pathFile);
        // UserMakeTag userMakeTag=new UserMakeTag(UserMakeTag.SETCOVER);
        EventBus.getDefault().post(userMakeTag);
    }

    @Override
    public void finish() {
        super.finish();
        //注释掉activity本身的过渡动画
        overridePendingTransition(R.anim.slide_left_in, R.anim.slide_right_out);  //解决退出动画无效
        // overridePendingTransition(0, 0);
    }

    public class CocerVideoAdapter extends VideoAdapter {

        //设置三种不同Item类型,分别是头部,item,尾部
        public static final int ITME_TYPE_HEADER = 1;
        public static final int ITME_TYPE_CONTENT = 2;
        public static final int ITME_TYPE_BOTTOM = 3;

        public CocerVideoAdapter(Context context, List<Bitmap> datas, int itemLayoutId) {
            super(context, datas, itemLayoutId);
        }


        @Override
        protected void convert(BaseRecyclerHolder var1, Bitmap var2, int var3) {
            if (getItemViewType(var3) == ITME_TYPE_CONTENT) {
                ImageView imageView = var1.getView(R.id.id_ig_place);
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
                layoutParams.width = mItemWidth;
                if (var2 == null) {
                    Drawable drawable = UIUtils.getDrawable(R.drawable.place_icon);//获取drawable
                    BitmapDrawable bd = (BitmapDrawable) drawable;
                    Bitmap bm = bd.getBitmap();
                    imageView.setImageBitmap(bm);
                    // imageView.setImageBitmap(list.get(var3));
                } else {
                    imageView.setImageBitmap(list.get(var3));
                }
            }
        }


        @Override
        public BaseRecyclerHolder onCreateViewHolder(ViewGroup viewGroup, int i, boolean b) {
            View view;
            if (ITME_TYPE_HEADER == i) {
                view = getHeadView();
            } else if (ITME_TYPE_BOTTOM == i) {
                view = getFootView();
            } else {
                view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.video_item, viewGroup, false);

            }
            return new BaseRecyclerHolder(view);
        }

        @Override
        public int getItemViewType(int position) {
            if (position == 0) {
                return ITME_TYPE_HEADER;
            } else if (position == list.size() - 1) {
                return ITME_TYPE_BOTTOM;
            } else {
                return ITME_TYPE_CONTENT;
            }
        }


    }

    public class OnRecyclviewSollerListener extends RecyclerView.OnScrollListener {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {

            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            scrollX = getScrollXDistance();
            L_.e("onScrolled:" + scrollX);
            //保证不截取到封面
            if (scrollX <= converWidth) {
                scrollX += converWidth;
            }
            L_.e("startscrollPos averageMsPx * scrollX  " + scrollX);
            startscrollPos = averageMsPx * scrollX;
            L_.e("startscrollPos averageMsPx * scrollX  " + startscrollPos);

            //保证时长小于总时间
            if (startscrollPos >= mDuration) {
                startscrollPos = mDuration;
            }
            if (startscrollPos < 0) {
                startscrollPos = 0;
            }
            L_.e("startscrollPos currentPosition -= (converDuration * 1000)  " + startscrollPos);
            //请求接口

            //id_tv_show_tag.setText("当前时刻：" + format);
            if (id_ig_show_tag.getVisibility() == View.VISIBLE) {
                id_ig_show_tag.setVisibility(View.GONE);
            }
            L_.e("startscrollPos startscrollPos -= (converDuration * 1000)  " + startscrollPos);
            //landLayoutVideo.stopseekTo((long) startscrollPos);

            if (frameTimes != null) {
                // int i=(int) Math.ceil(startscrollPos);
                Double aDouble = Double.valueOf(startscrollPos / 1000);
                Double integer = binarysearchKey(frameTimes, aDouble);
                startscrollPos = integer * 1000;
            }
            DecimalFormat df = new DecimalFormat("#0.0000");
            String format = df.format(startscrollPos / 1000);
            // id_tv_show_tag.setText("当前时刻：" + format);
            landLayoutVideo.stopseekTo((long) startscrollPos);

        }
    }
}
